import 'dart:io';

import 'package:bigegg/common/log/xmm_logcat.dart';

class XmmFileUtil {
  static Future<bool> copyFile(String srcPath, String destPath) async {
    try {
      File source = File(srcPath);
      File destination = File(destPath);
      await destination.create(recursive: true);
      File file = await source.copy(destination.path);
      if (file.existsSync()) {
        return true;
      }
    } catch (e, s) {
      XmmXLogcat.e('$e  $s');
    }
    return false;
  }

  /// 判断文件是否存在
  static Future<bool> isFileExists(String path) async {
    try {
      File file = File(path);
      return await file.exists();
    } catch (e) {
      XmmXLogcat.e(e);
      return false;
    }
  }

  static void deleteFile(String path) {
    File file = File(path);
    if (file.existsSync()) {
      file.delete();
    }
  }
}
